//
//  GQMineViewController.m
//  MyMusic
//
//  Created by sunny on 16/4/14.
//  Copyright © 2016年 sunny. All rights reserved.
//

#import "GQMineViewController.h"
#import "GQAccountViewController.h"

@interface GQMineViewController () <UITableViewDelegate>

@end

@implementation GQMineViewController

+ (instancetype)mineViewController
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"GQMineViewController" bundle:nil];
    return [storyboard instantiateInitialViewController];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.contentInset = UIEdgeInsetsMake(-35, 0, 0, 0);
    self.tableView.delegate = self;
    
//    设置导航条上的内容
    [self setupNav];
}

#pragma mark - 设置导航条上的内容
- (void)setupNav
{
    //    设置左边的按钮
    UIButton *leftButton = [[UIButton alloc] init];
    [leftButton setTitle:@"更多" forState:UIControlStateNormal];
    [leftButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
    [leftButton addTarget:self action:@selector(pushToAccountVC) forControlEvents:UIControlEventTouchUpInside];
    [leftButton sizeToFit];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    
    //    设置右边的button
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem addButtonWithImage:[UIImage imageNamed:@"cm2_topbar_icn_playing"] highlightedfImage:[UIImage imageNamed:@"cm2_topbar_icn_playing_prs"] addTarget:self action:@selector(playing:)];
}

//播放按钮的点击
- (void)playing:(UIButton *)btn
{
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
    UIViewController *vc = [[UIStoryboard storyboardWithName:@"QQListTVC" bundle:nil]instantiateInitialViewController];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)pushToAccountVC
{
    GQAccountViewController *vc = [[UIStoryboard storyboardWithName:@"GQAccountViewController" bundle:nil] instantiateInitialViewController];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        [self playing:nil];
    }
}

@end
